package com.example.dormmanage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.dormmanage.entity.Admin;
import com.example.dormmanage.entity.Role;
import com.example.dormmanage.service.impl.RoleService;
import com.example.dormmanage.view.ResultView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/role")
@Api(tags = "角色管理")
@Slf4j
public class RoleManageController {

    @Autowired
    private RoleService roleService;


    @GetMapping()
    @ApiOperation("查询角色列表")
    public ResultView<Page> selectRoleList(Integer page, Integer pageSize, String name){
        return roleService.selectRoleList(page,pageSize,name);
    }


    @PostMapping()
    @ApiOperation("添加角色")
    public ResultView<String> addRole(@RequestBody Role role){
        return roleService.addRole(role);
    }

    @GetMapping("/{roleId}")
    @ApiOperation("查询角色详情")
    public ResultView<Role> selectAdminData(@PathVariable Integer roleId){
        return roleService.selectAdminData(roleId);
    }



}
